import { request } from "@umijs/max"

// 获得表格数据
export function GetListFnc (data: {type: number, pageNum: number, pageSize: number}) { 
    return request(`/categories?type=${data.type}&pageNum=${data.pageNum}&pageSize=${data.pageSize}`, {
      method: 'get'
    })
  }

  // 获得级联选择器数据
  export function GetCascaderFnc (data: {type: number}) { 
    return request(`/categories?type=${data.type}`, {
      method: 'get'
    })
  }

  // 添加分类
  export function AddCategoryFnc (data: any) { 
    return request('/categories', {
       method: 'post',
       data: data
    })
  }

  // 编辑分类名称
  export function EditCategoryFnc (id: number, data: {cat_name: string}) { 
    return request(`/categories/${id}`, {
      data: data,
      method: 'put'
    })
  }


  // 删除分类
  export function DeleteCateogryFnc (id: number) {
    return request(`/categories/${id}`, {
      method: 'delete'
    })
  }